date.format ( theDate ; format )
A function to return a date in a text format specified at the time.
Average rating: 3.7 (69 votes) Log in to vote
Tim Anderson - Show more from this author
Tim Anderson Group |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
A function to return a date in a text format specified at the time.
Parameters:
theDate
format
Example:
date.format( get(currentdate); dd-mon-yy) - returns 03-Aug-08
Requires Other Custom Functions:
None
Other Notes:
Uses substitute function so is very simple for you to add your favourite abbreviation - just watch the substitution order!.
Thought I'd seen something like this before, but couldn't find it
Updated 19 March 2018 to my current use because if new comments. Replaced 'dn' with 'dn3' to stop issues with Wednesdays and removed the extra entry for 'year'
Comments
Will Loving, Dedication Technologies, Inc. Oct 11, 2013 |
||
There is a problem with your variables. If the day of the week is Wednesday, then using "dname" correctly calculates "Wednesday" but then the next substitution for "dn" re-writes the "dn" in Wednesday to "WeWedesday". It's easy enough to use a different variable name but I thought I would point out the problem. | ||
beverly, KY Apr 2, 2016 |
||
I think I'd add 'm' (not padded) and 'd' (not padded). or perhaps I'd look at the way PHP handles date string functions (using the same "formats"): http://php.net/manual/en/function.date.php just to make it consistent in this function. So month would have 'F', 'm', 'M' or 't' choices. |
||
kevin rehak, collegeville, PA Mar 15, 2018 |
||
make sure to add quotes around format. date.format ( date ; "mm-dd-yyyy" ) |
||
Richard DeShong, Logic Tools Mar 19, 2018 |
||
Hi Tim, noticed that "year" is listed twice. | ||
Tim, JEAMA Mar 19, 2018 |
||
Thanks Richard. I had changed this in my solution along ago, removing the extra 'year'. But your comment and made me realise I had not updated this with the fix for wednesdays - now updated. Beverly, I know next to nothing about php, I would imagine for those that would want consistency across their platforms they could easily follow what I have done here and tweak it for their own preference. |
||
Ed, Santa Cruz May 26, 2018 |
||
It's very sad that something that ought to be straightforward and simple as formatting a date field is barely accomplished using complex Rube Goldberg methods. Also, beg the question as to why my CurrentDate field no long formatted as desired and also prints the year using Japanese characters. | ||
DUBAU Jan 25, 2019 |
||
Hello I need to name files as follows : YYYYMMDDHHMNSS (for sample 20190125160504) Is there such a function in your rich library ? Thanks |
||
Tim Anderson, Tim Anderson Group Jan 31, 2019 |
||
DUBAU, I have just uploaded a new cf - FilenameFromTimestamp - that should be available soon. Should be easy too tweak if you need Tim |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.